package cc.devclub.ftd.thread.lifecycle;

public class LifeCycle extends Thread {
    @Override
    public void run() {
        int n = 0;
        while ((++n) < 1000) {
            // do nothing
        }
    }

    public static void main(String[] args) throws Exception {
        LifeCycle thread1 = new LifeCycle();
        System.out.println("isAlive: " + thread1.isAlive());
        thread1.start();
        System.out.println("isAlive: " + thread1.isAlive());
        thread1.join(); // main线程需要等线程thread1结束后再继续执行
        System.out.println("thread1已经结束!");
        System.out.println("isAlive: " + thread1.isAlive());
    }
}